package com.study.day20190709;

public class ThreadTest extends Thread{

    public ThreadTest(String name){
        super(name);
    }

    @Override
    public void run() {
        while (!interrupted()){
            System.out.println(getName() +"线程执行了");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        ThreadTest t1=new ThreadTest("first");
        ThreadTest t2 = new ThreadTest("second");
        t1.start();
        t2.start();
        t1.interrupt();
    }
}
